<?php
include_once '../../Config/config.php';
include_once '../../Config/conexion.php';
include_once '../../Model/Revisor.php';
include_once '../../Model/Paper.php';

//print_r($_POST);
//exit();


$idpaper = isset($_POST['idpaper'])?$_POST['idpaper']:'';
$action = $_POST['action'];

if($action == "cambiarsala"){
	$idsala = isset($_POST['idsala'])?$_POST['idsala']:'';
	$paper = Paper::Obtener($idpaper);
	$paper->IdSala = $idsala;
	
	$exito = "1";
	if(Paper::VerificarDisponibilidadPorIdiomaTrack($paper->Idioma->Id, $paper->Track->Id, $paper->IdHorario, $paper->IdSala)){
		$paper->Actualizar();
	}else{
		$exito = "0";
	}
	echo '{"exito":"'.$exito.'" }';
	exit();
}

if($action == "cambiarhorario"){
	$idhorario = isset($_POST['idhorario'])?$_POST['idhorario']:0;

	$paper = Paper::Obtener($idpaper);
	$paper->IdHorario = $idhorario;
	
	$exito = "1";
	if(Paper::VerificarDisponibilidadPorIdiomaTrack($paper->Idioma->Id, $paper->Track->Id, $paper->IdHorario, $paper->IdSala)){
		$paper->Actualizar();
	}else{
		$exito = "0";
	}
	echo '{"exito":"'.$exito.'" }';
	exit();
}